# Contributor: Antoine Martin (ayakael) <dev@ayakael.net>
# Maintainer: Antoine Martin (ayakael) <dev@ayakael.net>
pkgname=py3-pytube
#_pkgreal is used by apkbuild-pypi to find modules at PyPI
_pkgreal=pytube
pkgver=15.0.0
pkgrel=1
pkgdesc="Python 3 library for downloading YouTube Videos."
url="https://pypi.python.org/project/pytube"
arch="noarch"
license="Unlicense"
checkdepends="py3-pytest"
makedepends="py3-setuptools py3-gpep517 py3-wheel"
source="$pkgname-$pkgver.tar.gz::https://github.com/pytube/pytube/archive/refs/tags/v$pkgver.tar.gz"
builddir="$srcdir/$_pkgreal-$pkgver"
subpackages="$pkgname-pyc"
# 7/131 units failing due to:
#   AttributeError: 'NoneType' object has no attribute 'register_on_progress_callback'
#   AttributeError: 'YouTube' object has no attribute 'stream_monostate'
#   StopIteration
options="!check"

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer "$builddir"/.dist/*.whl
	.testenv/bin/python3 -m pytest -v
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl
}

sha512sums="
fc28d87c56bae9da3def68224a03687cc521c26e6f38dd41abe81e84f91bb2cab73dc8c7dbbc388787cf066f7d7304c78162cc60c544b99e75187b760c64b4a3  py3-pytube-15.0.0.tar.gz
"
